Trapping Rain Water II
Question
Given an m x n matrix of positive integers representing the height of each unit cell in a 2D elevation map, compute the volume of water it is able to trap after raining.
Note:
Both m and n are less than 110. The height of each unit cell is greater than 0 and is less than 20,000.
Example:
|
|
Analysis
Code
|
|
First Missing Positive
Question
Given an unsorted integer array, find the first missing positive integer.
For example,
Given[1,2,0]
return 3
,
and [3,4,-1,1]
return2
.
Analysis
从头到尾遍历,将每个大于0且小于等于长度len的数i都放在数组i-1的位置上,最后再从头遍历一次,找到第一个num[i]!=i+1的即所需结果
Code
|
|